# Python 2.6.4
# Project Euler, Problem 139
# Copyright 2010 Talha Zaman

def gcd(a, b):
    a, b = sorted([a, b])
    while a%b: a, b = b, a%b
    return b

def PPT():
    uv = 3
    while uv<=10000:
        for u in range(1,1+uv/2):
            v = uv - u
            if gcd(u, v)!=1: continue
            yield sorted([v**2-u**2, 2*u*v, v**2+u**2])
        uv += 2
from time import clock
start = clock()
count = 0
for t in PPT():
    if t[2]%(t[1]-t[0])==0:
        count += 99999999 / (t[0]+t[1]+t[2])
stop = clock()
print count
print stop-start
